﻿Imports ADODBU
Imports CoreClassLibraryCMS

<HandleError()> _
Public Class HomeController
    Inherits System.Web.Mvc.Controller

    Function Index() As ActionResult
        If Not Me.User.Identity.IsAuthenticated Then
            Response.Redirect("~/Login.aspx")
        End If
        ViewData("Message") = "Welcome to ASP.NET MVC!"

        Return View()
    End Function

    Function About() As ActionResult
        Return View()
    End Function

    <AcceptVerbs(HttpVerbs.Post)> _
    Public Function getModule() As ActionResult


        Dim vd As UserAccess = New UserAccess()

        RowClassUtil.RowClassFill(vd, RowClassUtil.GetASCIIStringFromBytes(Request.BinaryRead(Request.TotalBytes)))
        Trustee.GetModule(vd)
        Dim m = New CoreClassLibraryCMS.Models.ModuleExec(vd.ModuleID).ListJS
        Dim v = New With {.title = vd.title, .id = vd.id, .url = vd.url, .htm = m}
        Return Json(v)
    End Function

    <AcceptVerbs(HttpVerbs.Post)> _
    Public Function getReport() As ActionResult


        Dim vd As UserAccess = New UserAccess()

        RowClassUtil.RowClassFill(vd, RowClassUtil.GetASCIIStringFromBytes(Request.BinaryRead(Request.TotalBytes)))
        Trustee.GetModule(vd)

        If vd.id Is Nothing Then
            vd.id = vd.ModuleID
            vd.htm = ""
            vd.title = ""
            vd.htm = ""
            vd.url = ""

        End If
        Dim m = New CoreClassLibraryCMS.Models.ModuleExec(vd.ModuleID).ListJS
        Dim htm As String = ""
        Dim v = New With {.success = True, .title = vd.title, .id = vd.id, .url = vd.url, .htm = m, .havedialog = (m.Count <> 0)}
        Return Json(v)
    End Function

End Class
